package com.gy.def.handler;

import com.gy.def.exception.GySchoolException;
import com.gy.def.utils.ResultVoUtil;
import com.gy.def.viewobject.ResultVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 自定义异常拦截
 */
@ControllerAdvice
public class GySchoolExceptionHandler {

  @ExceptionHandler(value = GySchoolException.class)
  @ResponseBody
  public ResultVo handlerGYException(GySchoolException e) {
    return ResultVoUtil.error(e.getCode(), e.getMessage());
  }

}
